package cn.wolfcode.shop.mapper;

import cn.wolfcode.shop.domain.SeckillGood;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SeckillGoodMapper {

    @Select("SELECT * FROM t_seckill_goods")
    List<SeckillGood> listAll();

    @Select("SELECT * FROM t_seckill_goods WHERE id = #{seckillGoodId}")
    SeckillGood selectByPrimaryKey(Long seckillGoodId);

    @Update("UPDATE t_seckill_goods SET stock_count = stock_count - 1 WHERE id = #{seckillId} AND stock_count > 0")
    int decrStockCount(Long seckillId); //返回受影响的行数
}
